function showDialog(id) {document.getElementById(id + "dialogForm").reset();if(document.getElementById("errorDIV")){document.getElementById("errorDIV").innerHTML = "";} document.getElementById(id + 'dialogDIV').style.display = 'block';document.getElementById(id + "coverBgDIV").style.display = "block";document.getElementById(id + "coverBgDIV").style.height = document.documentElement.clientHeight;if(document.getElementById(id + "dialogForm") != undefined){try{for(var i = 0;i<document.getElementById(id + "dialogForm").length;i++){if(document.getElementById(id + "dialogForm")[i].type != "hidden" && document.getElementById(id + "dialogForm")[i].type != "select-one"){document.getElementById(id + "dialogForm")[i].focus();return;}}}catch(e){}}}
function hiddenDialog(id) {document.getElementById(id + 'dialogDIV').style.display = 'none';document.getElementById(id + "coverBgDIV").style.display = "none";return false;}
function getSubmitStr(id) {var form = document.getElementById(id + 'dialogForm');var param = '';if(form.length > 0 && form != undefined) {for(var i = 0;i<form.length;i++) {var obj = form[i];var val = '';if(obj.type == 'text' || obj.type == 'hidden' || obj.type == 'select-one') {	val = obj.value;}else if(obj.type == 'textarea') {	val = obj.innerHTML;}else if(obj.type == 'checkbox' || obj.type == 'radio') {	if(obj.checked) {		val = obj.value;	}}	if(val != '') {	if(param == '') {		param += obj.name + '=' + val;	}else{		param += '&' + obj.name + '=' + val;	}}}}return param;}
function hiddenDialogSim(id) {hiddenDialog(id);if(typeof(simpleSure) == "function"){simpleSure();}else{window.location.reload();}}

function fillInValue(json) {
	if(json!=null){
		for(var id in json) {
			if(document.getElementById(id) != undefined) {
				document.getElementById(id).value = json[id];
			}
		}
	}
}

function validateInput(formID){
	var flag=true;//是否允许提交表单
	var form = document.getElementById(formID + "dialogForm");
	if(form != undefined && form.length > 0) {
	  for(var i = 0; i < form.length;i++) {
	   if(form[i].attributes["test"] != undefined && (form[i].type == "text" || form[i].type == "textarea") || form[i].type == "password"){
		var reg=new RegExp(form[i].attributes["test"].nodeValue);
		if(!reg.test(form[i].value)){
			flag=false;
			try{
				var msg = "格式不正确!";
				if(form[i].attributes["msg"] != undefined && form[i].attributes["msg"].nodeValue != undefined) {
					 msg = form[i].attributes["msg"].nodeValue;
				}
				form[i].focus();
				document.getElementById("errorDIV").innerHTML = msg;
			}catch(e){}
			return false;
		}
	   }
	  }
	}
	return flag;
}

function setDialogContent(id, content) {
	document.getElementById(id).innerHTML = content;
}

function setFormAction(id,actionName) {
	document.getElementById(id + "dialogForm").action = actionName;
}

function setTitle(id,title) {
	document.getElementById(id + "titleSpan").innerHTML = title;
}

function getForm(id) {
	return document.getElementById(id + "dialogForm");
}

document.onkeypress = function() {document.getElementById("errorDIV").innerHTML = "";}